load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//build:STRINGER.bzl", "stringer")

go_library(
    name = "lease",
    srcs = [
        "count.go",
        "descriptor_set.go",
        "descriptor_state.go",
        "descriptor_version_state.go",
        "kv_writer.go",
        "lease.go",
        "lease_test_utils.go",
        "name_cache.go",
        "storage.go",
        "testutils.go",
        ":gen-lease-mode-stringer",  # keep
    ],
    importpath = "github.com/cockroachdb/cockroach/pkg/sql/catalog/lease",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/base",
        "//pkg/keys",
        "//pkg/kv",
        "//pkg/kv/kvclient/rangefeed",
        "//pkg/kv/kvpb",
        "//pkg/multitenant",
        "//pkg/roachpb",
        "//pkg/server/serverpb",
        "//pkg/server/settingswatcher",
        "//pkg/settings",
        "//pkg/settings/cluster",
        "//pkg/sql/catalog",
        "//pkg/sql/catalog/bootstrap",
        "//pkg/sql/catalog/catalogkeys",
        "//pkg/sql/catalog/descbuilder",
        "//pkg/sql/catalog/descpb",
        "//pkg/sql/catalog/internal/catkv",
        "//pkg/sql/catalog/internal/validate",
        "//pkg/sql/catalog/nstree",
        "//pkg/sql/catalog/systemschema",
        "//pkg/sql/catalog/tabledesc",
        "//pkg/sql/enum",
        "//pkg/sql/isql",
        "//pkg/sql/pgwire/pgcode",
        "//pkg/sql/pgwire/pgerror",
        "//pkg/sql/regionliveness",
        "//pkg/sql/sem/tree",
        "//pkg/sql/sessiondata",
        "//pkg/sql/sqlliveness",
        "//pkg/sql/sqlliveness/slbase",
        "//pkg/storage",
        "//pkg/util/grpcutil",
        "//pkg/util/hlc",
        "//pkg/util/log",
        "//pkg/util/log/logcrash",
        "//pkg/util/metric",
        "//pkg/util/quotapool",
        "//pkg/util/retry",
        "//pkg/util/startup",
        "//pkg/util/stop",
        "//pkg/util/syncutil",
        "//pkg/util/syncutil/singleflight",
        "//pkg/util/timeutil",
        "//pkg/util/tracing",
        "//pkg/util/tracing/tracingpb",
        "//pkg/util/uuid",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_logtags//:logtags",
        "@com_github_cockroachdb_redact//:redact",
    ],
)

stringer(
    name = "gen-lease-mode-stringer",
    src = "lease.go",
    typ = "SessionBasedLeasingMode",
)

go_test(
    name = "lease_test",
    size = "large",
    srcs = [
        "helpers_test.go",
        "ie_writer_test.go",
        "kv_writer_test.go",
        "lease_internal_test.go",
        "lease_test.go",
        "main_test.go",
    ],
    embed = [":lease"],
    exec_properties = {
        "test.Pool": "heavy",
    },
    shard_count = 4,
    deps = [
        "//pkg/base",
        "//pkg/clusterversion",
        "//pkg/jobs",
        "//pkg/jobs/jobspb",
        "//pkg/keys",
        "//pkg/kv",
        "//pkg/kv/kvpb",
        "//pkg/kv/kvserver",
        "//pkg/kv/kvserver/kvserverbase",
        "//pkg/roachpb",
        "//pkg/security/securityassets",
        "//pkg/security/securitytest",
        "//pkg/server",
        "//pkg/server/settingswatcher",
        "//pkg/settings/cluster",
        "//pkg/sql",
        "//pkg/sql/catalog",
        "//pkg/sql/catalog/catalogkeys",
        "//pkg/sql/catalog/descbuilder",
        "//pkg/sql/catalog/descpb",
        "//pkg/sql/catalog/descs",
        "//pkg/sql/catalog/desctestutils",
        "//pkg/sql/catalog/systemschema",
        "//pkg/sql/catalog/tabledesc",
        "//pkg/sql/enum",
        "//pkg/sql/isql",
        "//pkg/sql/pgwire/pgcode",
        "//pkg/sql/pgwire/pgerror",
        "//pkg/sql/regions",
        "//pkg/sql/rowenc/keyside",
        "//pkg/sql/rowenc/valueside",
        "//pkg/sql/schemachanger/scexec",
        "//pkg/sql/schemachanger/scop",
        "//pkg/sql/schemachanger/scplan",
        "//pkg/sql/sem/tree",
        "//pkg/sql/sessiondata",
        "//pkg/sql/sqlinstance/instancestorage",
        "//pkg/sql/sqlliveness",
        "//pkg/sql/sqlliveness/slbase",
        "//pkg/sql/sqlliveness/slprovider",
        "//pkg/sql/types",
        "//pkg/storage",
        "//pkg/testutils",
        "//pkg/testutils/serverutils",
        "//pkg/testutils/skip",
        "//pkg/testutils/sqlutils",
        "//pkg/testutils/testcluster",
        "//pkg/util/admission",
        "//pkg/util/ctxgroup",
        "//pkg/util/encoding",
        "//pkg/util/hlc",
        "//pkg/util/leaktest",
        "//pkg/util/log",
        "//pkg/util/randutil",
        "//pkg/util/retry",
        "//pkg/util/syncutil",
        "//pkg/util/timeutil",
        "//pkg/util/uuid",
        "@com_github_cockroachdb_cockroach_go_v2//crdb",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_logtags//:logtags",
        "@com_github_lib_pq//:pq",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
    ],
)
